/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package traffic.light.simulator.town.unity;

/**
 *
 *
 */
class TownUnityType10 extends TownUnity {

    public TownUnityType10(int positionX, int positionY, int townSize) {
        super(CrossRoadType.TYPE_10, positionX, positionY, townSize);
    }

    @Override
    public void generateCorrespondantUnity() {
        super.generateCorrespondantUnity();
        
        townElements[0][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(0), RoadType.DOWN);
        townElements[0][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(0), RoadType.UP);
        townElements[1][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(1), RoadType.DOWN);
        townElements[1][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(1), RoadType.UP);
        townElements[2][0] = new RoadElement(absoluteElementXPosition(0), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][1] = new RoadElement(absoluteElementXPosition(1), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(2), RoadType.LEFT);
        townElements[2][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(2), RoadType.UP);
        townElements[3][0] = new RoadElement(absoluteElementXPosition(0), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][1] = new RoadElement(absoluteElementXPosition(1), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(3), RoadType.RIGHT);
        townElements[3][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(3), RoadType.UP);
        generateAccessibleElements();
        generateTL();
    }

    @Override
    protected void generateAccessibleElements() {
        if (positionX == 0 || positionY == 0) {
            this.isAccessibleForMovableEntities = true;
            if (positionX == 0) {
                this.accessibleTownElement = townElements[3][0];
            } else if (positionY == 0) {
                this.accessibleTownElement = townElements[0][2];
            }
        }
    }
}
